#pragma once
#include "../functions.h"

void even_and_odd() {
  string input_str = input("Enter a comma-separated list of numbers:");
  stringstream ss(input_str);
  vector<int> nums;
  string segment;

  while (getline(ss, segment, ',')) {
    nums.push_back(stoi(segment));
  }

  vector<int> even_nums, odd_nums;
  for (int num : nums) {
    if (num % 2 == 0) {
      even_nums.push_back(num);
    } else {
      odd_nums.push_back(num);
    }
  }

  cout << "Even numbers: ";
  for (int i = 0; i < even_nums.size(); ++i) {
    cout << even_nums[i];
    if (i != even_nums.size() - 1)
      cout << ", ";
  }
  cout << endl;

  cout << "Odd numbers: ";
  for (int i = 0; i < odd_nums.size(); ++i) {
    cout << odd_nums[i];
    if (i != odd_nums.size() - 1)
      cout << ", ";
  }
  cout << endl;
}